<template>
	<view class="all-box containers" style="margin-bottom:200rpx;">
		<view v-if="netWorkType!='none'">
			<tui-skeleton v-if="skeletonShow" backgroundColor="#fafafa" borderRadius="10rpx"></tui-skeleton>
			<view v-if="data.detail.product_type==1"  class="data-box sp-box">

				<view>
					<view  style="font-size: 72rpx;color: #222222;font-weight: 700;">{{data.detail.sp}}/{{data.detail.dp}}</view>
					<view>
						<view class="rg">
							<view  >
								mmHg
								<tui-tag v-if="data.detail.sp<140" padding="12rpx"  type="dev-green">正常</tui-tag>
								<tui-tag v-else padding="12rpx" type="dev-red">异常</tui-tag>
							</view>
						</view>
					</view>
				</view>
				<view>
					<view  style="font-size: 72rpx;color: #222222;font-weight: 700;">{{data.detail.heart}}</view>
					<view>
						<view class="rg">
							<view  >
								bpm
								<tui-tag v-if="data.detail.heart_status==0" padding="12rpx" type="dev-green">正常</tui-tag>
								<tui-tag v-else padding="12rpx" type="dev-red">异常</tui-tag>
							</view>
						</view>
					</view>
				</view>
			</view>
			<view v-else class="data-box  ">
				<view  style="font-size: 112rpx;color: #222222;font-weight: 700;">{{data.detail.product_type==3?data.detail.glu:data.detail.ua}}</view>

				<view>
					<view class="rg">
						<view v-if="data.detail.product_type==3">
							{{data.detail.unit_type_desc}}
							<tui-tag v-if="data.detail.status==1"  padding="12rpx" type="dev-green">正常</tui-tag>
							<tui-tag v-if="data.detail.status==2" padding="12rpx" type="dev-red">异常</tui-tag>
							<tui-tag v-if="data.detail.status==3" padding="12rpx" type="dev-red">异常</tui-tag>
						</view>
						<view v-else>
							μmol/L
							<tui-tag v-if="data.detail.status==1"  padding="12rpx" type="dev-green">正常</tui-tag>
							<tui-tag v-if="data.detail.status==2" padding="12rpx" type="dev-red">异常</tui-tag>
						</view>
					</view>
				</view>
			</view>

			<view class="container tui-skeleton">
				<view class="pad-all15 detail">
					<view class="flex-box padbottom17">
						<text class="font-gray">测量日期</text>
						<text class="right">{{data.detail.date}}</text>
					</view>
					<view class="flex-box padbottom17">
						<text class="font-gray">测量时间</text>
						<text class="right">{{data.detail.time}}</text>
					</view>

					<view class="padbottom10" style="color: #222222;font-size: 30rpx;">添加备注</view>
					<view class="remark">
						<textarea v-model="data.detail.remark" placeholder="点击输入备注信息"></textarea>
					</view>
					<view class="text-center padtop15">
						<text  @tap="introduction(data.detail.product_type)" style="color: #60AFFF;">点击查看测试结果说明</text>
					</view>
				</view>

				<!-- 保存 -->
				<view class="bottom-action">
					<view class="save" @tap="save">保存</view>
					<view @tap="del" class="del margin-bottom20">删除数据</view>

				</view>
				<!-- 保存end -->

			</view>
		</view>
		<!-- 提示弹框 -->
		<tui-tips ref="toast"></tui-tips>
		<!-- 登录弹窗 -->
		<uni-popup-vlogin id="popupvLogin" ref="popupvLogin" type="bottom" />

	</view>
</template>
<script>
	import Vue from 'vue'
	import store from '@/store/index.js';
	// 公共底部
	import btabbar from '@/components/indexBottomTable/bottomtabbar.vue'
	import tuiTag from '@/components/tag/tag'
	import {
		mapGetters
	} from 'vuex';
	export default {
		components: {
			btabbar,
			tuiTag
		},
		computed: {
			//注册网络状态
			...mapGetters(['netWorkType','loginStatus'])
		},
		data() {
			return {
				// 骨架屏
				skeletonShow: true,
				fromFather:{
					id:''
				},
				data: {
					list: [],
					detail:[]
				}
			}
		},
		onLoad(e) {
			this.fromFather.id=e.id;
			this.getList(e.id)


		},
		onShow() {



		},
		methods: {
			// 血压测试结果说明
			introduction(product_type) {
				let _this = this

				this.$refer.setVilit('test_result')
				let callback = function(url) {
					_this.$refs.popupvLogin.open()
				}
				var data = {
					product_type:product_type
				}
				this.$refer.toUrl(callback, data)
				return
			},
			back(){
				let _this = this
				this.$refer.setVilit('test_record/test_record')
				let callback = function(url) {
					_this.$refs.popupvLogin.open()
				}

				var data = {
					group_id:_this.data.detail.group_id,
					product_type:_this.data.detail.product_type
				}

				this.$refer.toUrl(callback, data)

			},
			getList(id) {
				let _this = this
				let opt = {
					url: '/blutdruck_check/detail',
					method: 'get',
					data: {
						id:id,

					},
					success: function(res) {

						if (res.status == 1) {
							_this.skeletonShow=false;
							_this.data.detail=res.data;
						} else {

						}

					}
				};
				if (this.loginStatus) {
					this.$service.GetApi(opt) //网络
				}

			},
			save(){
				let _this = this

				let opt = {
					url: '/blutdruck_check/setRemark',
					method: 'get',
					data: {
						id:this.fromFather.id,
						remark:this.data.detail.remark

					},
					success: function(res) {

						if (res.status == 1) {
							// _this.data.detail=res.data;
							// _this.getList(_this.fromFather.id);
							let options = {
								msg: '保存数据成功',
								type: 'green'
							};
							_this.$refs.toast.showTips(options);
							_this.back()

						} else {

						}

					}
				};
				if (this.loginStatus) {

					this.$service.GetApi(opt) //网络
				}
			},

			//
			del(){
				let _this = this
				uni.showModal({
				    title: '提示',
				    content: '确认删除数据？删除后无法找回',
				    success: function (res) {
				        if (res.confirm) {
				            console.log('用户点击确定');
							_this.delFun()
				        } else if (res.cancel) {
				            console.log('用户点击取消');
				        }
				    }
				});
			},
			delFun(){
				let _this = this
				let opt = {
					url: '/blutdruck_check/delete',
					method: 'get',
					data: {
						id:this.fromFather.id,

					},
					success: function(res) {
						// console.log(res)
						if (res.status == 1) {
							let options = {
								msg: '删除数据成功',
								type: 'green'
							};
							_this.$refs.toast.showTips(options);
							_this.back()

						} else {
							let options = {
								msg: '删除数据失败',
								type: 'danger'
							};
							_this.$refs.toast.showTips(options);

						}

					}
				};
				if (this.loginStatus) {
					this.$service.GetApi(opt) //网络
				}
			}

		}
	}
</script>

<style lang="scss">
	@import "./detail.scss";
</style>
